// JavaScript Document中文
//交换标题的背景图片
function swampImage(o,img){
	//alert(o.background);
	if(o && img){
		//if(window.event){
			//o.background = img;
		//}else{
			o.style.backgroundImage = "url(" + img + ")";
		//}
	}
}
//预加载指定图片
function MM_preloadImages() { //v3.0
  var d=document; 
  //alert(d.images);
  if(d.images){ 
	if(!d.MM_p) 
		d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
	for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){
			d.MM_p[j]=new Image; 
			d.MM_p[j++].src=a[i];
		}
	}
}

function lazyload(option){
    var settings={
        defObj:null,
        defHeight:0
    };
    settings=$.extend(settings,option||{});
    var defHeight=settings.defHeight,defObj=(typeof settings.defObj=="object")?settings.defObj.find("img"):$(settings.defObj).find("img");
    var pageTop=function(){
        return document.documentElement.clientHeight+Math.max(document.documentElement.scrollTop,document.body.scrollTop)-settings.defHeight;
    };
    var imgLoad=function(){
		
        defObj.each(function(){
            if ($(this).offset().top<=pageTop()){
                var src2=$(this).attr("src2");
                if (src2){
                    $(this).attr("src",src2).removeAttr("src2");
                }
            }
        });
    };
    imgLoad();
    $(window).bind("scroll",function(){
        imgLoad();
    });
}
$(function(){
	lazyload({
		defObj:$(".content")
	});
})
